/*    */ package com.yc.comm;
/*    */ 
/*    */ import com.yc.dao.model.DictionaryBO;
/*    */ import java.sql.Connection;
/*    */ import java.sql.DriverManager;
/*    */ import java.sql.ResultSet;
/*    */ import java.sql.SQLException;
/*    */ import java.sql.Statement;
/*    */ import java.util.ArrayList;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import javax.servlet.http.HttpServlet;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.commons.logging.Log;
/*    */ import org.apache.commons.logging.LogFactory;
/*    */ 
/*    */ public class DirectoryInitServlet extends HttpServlet
/*    */ {
/* 28 */   private static final Log log = LogFactory.getLog(DirectoryInitServlet.class);
/* 29 */   public static Map dictMap = null;
/* 30 */   private String strDBFile = "/WEB-INF/db.xml";
/*    */ 
/*    */   public void init() {
/* 33 */     Connection con = null;
/* 34 */     Statement stmt = null;
/* 35 */     ResultSet rs = null;
/* 36 */     String url = "jdbc:mysql://localhost:3306/btsinfo";
/*    */     try
/*    */     {
/* 42 */       if (dictMap == null)
/*    */       {
/* 44 */         dictMap = new HashMap();
/*    */ 
/* 46 */         Class.forName("com.mysql.jdbc.Driver");
/* 47 */         con = DriverManager.getConnection(url, "root", "admin99");
/* 48 */         stmt = con.createStatement();
/*    */ 
/* 52 */         String strSQL = "select * from dictionary order by dictype";
/* 53 */         log.info(strSQL);
/* 54 */         rs = stmt.executeQuery(strSQL);
/* 55 */         while (rs.next()) {
/* 56 */           DictionaryBO bo = new DictionaryBO();
/* 57 */           String strdictype = rs.getString("dictype");
/* 58 */           bo.setDicname(rs.getString("dicname"));
/* 59 */           bo.setDictype(strdictype);
/* 60 */           bo.setDiccode(rs.getString("diccode"));
/* 61 */           List list = null;
/* 62 */           if (dictMap.containsKey(strdictype))
/*    */           {
/* 64 */             list = (List)dictMap.get(strdictype);
/*    */           }
/*    */           else
/* 67 */             list = new ArrayList();
/* 68 */           list.add(bo);
/* 69 */           dictMap.put(strdictype, list);
/*    */         }
/*    */       }
/* 72 */       com.yc.dao.station.CommDAO.dictMap = dictMap;
/*    */     }
/*    */     catch (Exception e) {
/* 75 */       e.printStackTrace();
/* 76 */       log.error(e.getMessage());
/*    */     }
/*    */     finally {
/* 79 */       if (stmt != null)
/*    */       {
/*    */         try {
/* 82 */           stmt.close();
/*    */         } catch (SQLException e) {
/* 84 */           e.printStackTrace();
/*    */         }
/* 86 */         stmt = null;
/*    */       }
/* 88 */       if (con != null)
/*    */       {
/*    */         try {
/* 91 */           con.close();
/*    */         } catch (SQLException e) {
/* 93 */           e.printStackTrace();
/*    */         }
/* 95 */         con = null;
/*    */       }
/*    */     }
/*    */   }
/*    */ 
/*    */   public void doGet(HttpServletRequest req, HttpServletResponse res)
/*    */   {
/*    */   }
/*    */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.comm.DirectoryInitServlet
 * JD-Core Version:    0.6.2
 */